home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- __all__ = 'load_icon'
- import gtk
- from gtk import gdk
- from os import path
- icon_theme = gtk.icon_theme_get_default()
- dir = path.dirname(__file__)
- icondir = path.join(dir, '..', 'icons')
- icon_theme.prepend_search_path(icondir)
- icon_cache = { }
-
- def load_icon(icon, size):
- if (icon, size) in icon_cache:
- return icon_cache[(icon, size)]
- icon_size = gtk.icon_size_lookup(size)[0]
- pixbuf = None
-
- try:
- pixbuf = gdk.pixbuf_new_from_file(icon)
- w = pixbuf.get_width()
- h = pixbuf.get_height()
- rate = max(w, h) / float(icon_size)
- w = int(w / rate)
- h = int(h / rate)
- pixbuf = pixbuf.scale_simple(w, h, gdk.INTERP_BILINEAR)
- except:
- (icon, size) in icon_cache
-
- icon_cache[(icon, size)] = pixbuf
- return pixbuf
-
-